#ifndef __VI_H__
#define __VI_H__

#ifdef __cplusplus
	extern "C" {
#endif

#include <linux/clk.h>
#include <linux/kthread.h>
#include <linux/mm.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h>
#include <linux/poll.h>
#include <linux/sched/signal.h>
#include <linux/slab.h>
#include <linux/streamline_annotate.h>
#include <linux/version.h>
#if (KERNEL_VERSION(4, 11, 0) <= LINUX_VERSION_CODE)
#include <uapi/linux/sched/types.h>
#endif

#include <linux/vi_tun_cfg.h>
#include <linux/vi_isp.h>
#include <linux/vi_uapi.h>
#include <linux/cvi_vi_ctx.h>
#include <vi_common.h>
#include <vip/vi_drv.h>
#include <snsr_i2c.h>
#include <vi_defines.h>
#include <vi_sdk_layer.h>
#include <reg_vip_sys.h>

#include <vi_raw_dump.h>

#define OFFLINE_RAW_BUF_NUM	2
#define OFFLINE_PRE_BE_BUF_NUM	2
#define OFFLINE_YUV_BUF_NUM	2
#define MAX_RGBMAP_BUF_NUM	3

enum cvi_isp_postraw_state {
	ISP_POSTRAW_IDLE,
	ISP_POSTRAW_RUNNING,
};

enum cvi_isp_pre_be_state {
	ISP_PRE_BE_IDLE,
	ISP_PRE_BE_RUNNING,
};

enum cvi_isp_preraw_state {
	ISP_PRERAW_IDLE,
	ISP_PRERAW_RUNNING,
};

/* struct mempool
 * @base: the address of the mempool
 * @size: the size of the mempool
 * @byteused: the number of bytes used
 */
struct _mempool {
	uint64_t base;
	uint32_t size;
	uint32_t byteused;
} isp_mempool;

struct _membuf {
	uint64_t bayer_le[OFFLINE_RAW_BUF_NUM];
	uint64_t bayer_se[OFFLINE_RAW_BUF_NUM];
	uint64_t prebe_le[OFFLINE_PRE_BE_BUF_NUM];
	uint64_t prebe_se[OFFLINE_PRE_BE_BUF_NUM];
	uint64_t yuv_yuyv[ISP_CHN_MAX][2];//yuv sensor is yuyv format
	uint64_t manr;
	uint64_t manr_rtile;
	uint64_t rgbmap_le[MAX_RGBMAP_BUF_NUM];
	uint64_t rgbmap_se[MAX_RGBMAP_BUF_NUM];
	uint64_t lmap_le;
	uint64_t lmap_se;
	uint64_t lsc;
	uint64_t tdnr[4];//0 for UV, 1 for Y, 2 for uv fbc double buffer, 3 for y fbc double buffer
	uint64_t tdnr_rtile[4];//tile
	uint64_t ir_le[OFFLINE_PRE_BE_BUF_NUM];
	uint64_t ir_se[OFFLINE_PRE_BE_BUF_NUM];
	uint64_t ldci;
	struct cvi_vip_isp_fswdr_report *fswdr_rpt;

	struct cvi_isp_sts_mem sts_mem[2];
	uint8_t pre_fe_sts_busy_idx;
	uint8_t pre_be_sts_busy_idx;
	uint8_t post_sts_busy_idx;
	uint8_t post_ir_busy_idx;

	spinlock_t pre_fe_sts_lock;
	uint8_t pre_fe_sts_in_use;
	spinlock_t pre_be_sts_lock;
	uint8_t pre_be_sts_in_use;
	spinlock_t post_sts_lock;
	uint8_t post_sts_in_use;
} isp_bufpool[ISP_PRERAW_VIRT_MAX] = {0};

struct isp_queue pre_out_queue[ISP_PRERAW_VIRT_MAX], pre_out_se_queue[ISP_PRERAW_VIRT_MAX],
	post_in_queue, post_in_se_queue,
	pre_be_in_q, pre_be_in_se_q[ISP_PRERAW_VIRT_MAX],
	pre_be_out_q, pre_be_out_se_q;

struct _isp_snr_i2c_node {
	struct snsr_regs_s n;
	struct list_head list;
};

struct _isp_crop_node {
	struct snsr_isp_s n;
	struct list_head list;
};

struct _isp_snr_cfg_queue {
	struct list_head list;
	uint32_t num_rdy;
} isp_snr_i2c_queue[ISP_PRERAW_VIRT_MAX], isp_crop_queue[ISP_PRERAW_VIRT_MAX];

struct _isp_raw_num_n {
	enum cvi_isp_raw raw_num;
	struct list_head list;
};

struct _isp_sof_raw_num_q {
	struct list_head	list;
} pre_raw_num_q;

struct _isp_dqbuf_n {
	u8		chn_id;
	u32		frm_num;
	struct timespec64 timestamp;
	struct list_head list;
};

struct _isp_dqbuf_q {
	struct list_head	list;
} dqbuf_q;

struct vi_event_k {
	struct vi_event		ev;
	struct list_head	list;
};

struct _isp_event_q {
	struct list_head	list;
} event_q;

struct _vi_buffer {
	__u32			chnId;
	__u32			sequence;
	struct timespec64	timestamp;
	__u32			reserved;
};


static u8 RGBMAP_BUF_IDX	= 2;

static spinlock_t raw_num_lock;
static spinlock_t dq_lock;
static spinlock_t snr_node_lock[ISP_PRERAW_VIRT_MAX];

static spinlock_t event_lock;

#if (KERNEL_VERSION(4, 15, 0) <= LINUX_VERSION_CODE)
typedef struct legacy_timer_emu {
	struct timer_list t;
	void (*function)(unsigned long);
	unsigned long data;
} _timer;
#else
typedef struct timer_list _timer;
#endif

_timer			usr_pic_timer;
static atomic_t		dev_open_cnt;

struct ip_info ip_info_list[IP_INFO_ID_MAX] = {
	//fe
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_PRE_RAW_FE0, sizeof(struct REG_PRE_RAW_FE_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_CSIBDG0, sizeof(struct REG_ISP_CSI_BDG_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL6, sizeof(struct REG_ISP_DMA_CTL_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL7, sizeof(struct REG_ISP_DMA_CTL_T)},
#if !defined(__CV180X__)
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL8, sizeof(struct REG_ISP_DMA_CTL_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL9, sizeof(struct REG_ISP_DMA_CTL_T)},
#endif
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_BLC0, sizeof(struct REG_ISP_BLC_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_BLC1, sizeof(struct REG_ISP_BLC_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_RGBMAP0, sizeof(struct REG_ISP_RGBMAP_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_WBG2, sizeof(struct REG_ISP_WBG_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL10, sizeof(struct REG_ISP_DMA_CTL_T)},
#if !defined(__CV180X__)
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_RGBMAP1, sizeof(struct REG_ISP_RGBMAP_T)},

	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_WBG3, sizeof(struct REG_ISP_WBG_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL11, sizeof(struct REG_ISP_DMA_CTL_T)},

	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_PRE_RAW_FE1, sizeof(struct REG_PRE_RAW_FE_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_CSIBDG1, sizeof(struct REG_ISP_CSI_BDG_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL12, sizeof(struct REG_ISP_DMA_CTL_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL13, sizeof(struct REG_ISP_DMA_CTL_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL14, sizeof(struct REG_ISP_DMA_CTL_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL15, sizeof(struct REG_ISP_DMA_CTL_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_BLC2, sizeof(struct REG_ISP_BLC_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_BLC3, sizeof(struct REG_ISP_BLC_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_RGBMAP2, sizeof(struct REG_ISP_RGBMAP_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_WBG4, sizeof(struct REG_ISP_WBG_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL16, sizeof(struct REG_ISP_DMA_CTL_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_RGBMAP3, sizeof(struct REG_ISP_RGBMAP_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_WBG5, sizeof(struct REG_ISP_WBG_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL17, sizeof(struct REG_ISP_DMA_CTL_T)},

	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_PRE_RAW_FE2, sizeof(struct REG_PRE_RAW_FE_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_CSIBDG2, sizeof(struct REG_ISP_CSI_BDG_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL18, sizeof(struct REG_ISP_DMA_CTL_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL19, sizeof(struct REG_ISP_DMA_CTL_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_BLC4, sizeof(struct REG_ISP_BLC_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_RGBMAP4, sizeof(struct REG_ISP_RGBMAP_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_WBG6, sizeof(struct REG_ISP_WBG_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL20, sizeof(struct REG_ISP_DMA_CTL_T)},
#endif
	//be
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_PRE_RAW_BE, sizeof(struct REG_PRE_RAW_BE_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_CROP0, sizeof(struct REG_CROP_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_CROP1, sizeof(struct REG_CROP_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_BLC5, sizeof(struct REG_ISP_BLC_T)},
#if !defined(__CV180X__)
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_BLC6, sizeof(struct REG_ISP_BLC_T)},
#endif
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_AF, sizeof(struct REG_ISP_AF_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL21, sizeof(struct REG_ISP_DMA_CTL_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DPC0, sizeof(struct REG_ISP_DPC_T)},
#if !defined(__CV180X__)
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DPC1, sizeof(struct REG_ISP_DPC_T)},
#endif
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL22, sizeof(struct REG_ISP_DMA_CTL_T)},
#if !defined(__CV180X__)
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL23, sizeof(struct REG_ISP_DMA_CTL_T)},
#endif
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_PRE_WDMA, sizeof(struct REG_PRE_WDMA_CTRL_T)},
	// {ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_PCHK0, sizeof(struct )},
	// {ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_PCHK1, sizeof(struct )},

	//raw_top
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_RAWTOP, sizeof(struct REG_ISP_RGBMAP_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_CFA, sizeof(struct REG_ISP_CFA_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_LSC, sizeof(struct REG_ISP_LSC_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL24, sizeof(struct REG_ISP_DMA_CTL_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_GMS, sizeof(struct REG_ISP_GMS_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL25, sizeof(struct REG_ISP_DMA_CTL_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_AEHIST0, sizeof(struct REG_ISP_AE_HIST_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL26, sizeof(struct REG_ISP_DMA_CTL_T)},
#if !defined(__CV180X__)
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_AEHIST1, sizeof(struct REG_ISP_AE_HIST_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL27, sizeof(struct REG_ISP_DMA_CTL_T)},
#endif
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL28, sizeof(struct REG_ISP_DMA_CTL_T)},
#if !defined(__CV180X__)
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL29, sizeof(struct REG_ISP_DMA_CTL_T)},
#endif
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_RAW_RDMA, sizeof(struct REG_RAW_RDMA_CTRL_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_BNR, sizeof(struct REG_ISP_BNR_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_CROP2, sizeof(struct REG_CROP_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_CROP3, sizeof(struct REG_CROP_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_LMAP0, sizeof(struct REG_ISP_LMAP_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL30, sizeof(struct REG_ISP_DMA_CTL_T)},
#if !defined(__CV180X__)
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_LMAP1, sizeof(struct REG_ISP_LMAP_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL31, sizeof(struct REG_ISP_DMA_CTL_T)},
#endif
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_WBG0, sizeof(struct REG_ISP_WBG_T)},
#if !defined(__CV180X__)
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_WBG1, sizeof(struct REG_ISP_WBG_T)},
#endif
	//rgbtop
	// {ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_PCHK2, sizeof(struct )},
	// {ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_PCHK3, sizeof(struct )},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_LCAC, sizeof(struct REG_ISP_LCAC_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_RGBCAC, sizeof(struct REG_ISP_RGBCAC_T)},

	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_RGBTOP, sizeof(struct REG_ISP_RGB_TOP_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_CCM0, sizeof(struct REG_ISP_CCM_T)},
#if !defined(__CV180X__)
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_CCM1, sizeof(struct REG_ISP_CCM_T)},
#endif
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_RGBGAMMA, sizeof(struct REG_ISP_GAMMA_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_YGAMMA, sizeof(struct REG_YGAMMA_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_MMAP, sizeof(struct REG_ISP_MMAP_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL32, sizeof(struct REG_ISP_DMA_CTL_T)},
#if !defined(__CV180X__)
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL33, sizeof(struct REG_ISP_DMA_CTL_T)},
#endif
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL34, sizeof(struct REG_ISP_DMA_CTL_T)},
#if !defined(__CV180X__)
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL35, sizeof(struct REG_ISP_DMA_CTL_T)},
#endif
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL36, sizeof(struct REG_ISP_DMA_CTL_T)},
#if !defined(__CV180X__)
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL37, sizeof(struct REG_ISP_DMA_CTL_T)},
#endif
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_CLUT, sizeof(struct REG_ISP_CLUT_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DHZ, sizeof(struct REG_ISP_DEHAZE_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_CSC, sizeof(struct REG_ISP_CSC_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_RGBDITHER, sizeof(struct REG_ISP_RGB_DITHER_T)},
	// {ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_PCHK4, sizeof(struct )},
	// {ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_PCHK5, sizeof(struct )},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_HIST_V, sizeof(struct REG_ISP_HIST_EDGE_V_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL38, sizeof(struct REG_ISP_DMA_CTL_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_HDRFUSION, sizeof(struct REG_FUSION_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_HDRLTM, sizeof(struct REG_LTM_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL39, sizeof(struct REG_ISP_DMA_CTL_T)},
#if !defined(__CV180X__)
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL40, sizeof(struct REG_ISP_DMA_CTL_T)},
#endif

	//yuvtop
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_YUVTOP, sizeof(struct REG_YUV_TOP_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_TNR, sizeof(struct REG_ISP_444_422_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL41, sizeof(struct REG_ISP_DMA_CTL_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL42, sizeof(struct REG_ISP_DMA_CTL_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_FBCE, sizeof(struct REG_FBCE_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL43, sizeof(struct REG_ISP_DMA_CTL_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL44, sizeof(struct REG_ISP_DMA_CTL_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_FBCD, sizeof(struct REG_FBCD_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_YUVDITHER, sizeof(struct REG_ISP_YUV_DITHER_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_CA, sizeof(struct REG_CA_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_CA_LITE, sizeof(struct REG_CA_LITE_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_YNR, sizeof(struct REG_ISP_YNR_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_CNR, sizeof(struct REG_ISP_CNR_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_EE, sizeof(struct REG_ISP_EE_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_YCURVE, sizeof(struct REG_ISP_YCURV_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DCI, sizeof(struct REG_ISP_DCI_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL45, sizeof(struct REG_ISP_DMA_CTL_T)},
	// {ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DCI_GAMMA, sizeof(struct )},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_CROP4, sizeof(struct REG_CROP_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL46, sizeof(struct REG_ISP_DMA_CTL_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_CROP5, sizeof(struct REG_CROP_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL47, sizeof(struct REG_ISP_DMA_CTL_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_LDCI, sizeof(struct REG_ISP_LDCI_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL48, sizeof(struct REG_ISP_DMA_CTL_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL49, sizeof(struct REG_ISP_DMA_CTL_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_PRE_EE, sizeof(struct REG_ISP_EE_T)},
	// {ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_PCHK6, sizeof(struct )},
	// {ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_PCHK7, sizeof(struct )},

	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_ISPTOP, sizeof(struct REG_ISP_TOP_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_WDMA_CORE0, sizeof(struct REG_WDMA_CORE_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_RDMA_CORE, sizeof(struct REG_RDMA_CORE_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_CSIBDG_LITE, sizeof(struct REG_ISP_CSI_BDG_LITE_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL0, sizeof(struct REG_ISP_DMA_CTL_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL1, sizeof(struct REG_ISP_DMA_CTL_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL2, sizeof(struct REG_ISP_DMA_CTL_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL3, sizeof(struct REG_ISP_DMA_CTL_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_WDMA_CORE1, sizeof(struct REG_WDMA_CORE_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_PRE_RAW_VI_SEL, sizeof(struct REG_PRE_RAW_VI_SEL_T)},
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL4, sizeof(struct REG_ISP_DMA_CTL_T)},
#if !defined(__CV180X__)
	{ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_DMA_CTL5, sizeof(struct REG_ISP_DMA_CTL_T)},
#endif
	// {ISP_TOP_PHY_REG_BASE + ISP_BLK_BA_CMDQ, sizeof(struct )},
};
/*************************************************************************
 *      Init once tuning parameter
 *************************************************************************/

u16 dci_map_lut[] = {
2,    3,    3,    5,    6,    7,    8,   10,   11,   13,   15,   16,   18,   20,   22,   25,
27,   29,   32,   34,   37,   39,   41,   44,   46,   50,   52,   55,   59,   62,   65,   69,
72,   75,   79,   84,   89,   93,   97,  100,  105,  109,  114,  119,  124,  128,  135,  140,
143,  149,  155,  159,  165,  170,  175,  181,  187,  194,  199,  205,  210,  217,  222,  229,
234,  239,  245,  250,  257,  263,  270,  276,  283,  289,  297,  304,  310,  318,  324,  330,
337,  344,  350,  356,  361,  368,  374,  381,  387,  394,  401,  408,  417,  425,  435,  442,
451,  459,  469,  477,  486,  496,  504,  515,  525,  535,  546,  557,  568,  579,  590,  601,
612,  623,  634,  645,  656,  668,  679,  690,  701,  712,  723,  734,  745,  757,  768,  779,
790,  801,  812,  823,  834, 845,  857,  868,  879,  890,  901,  911,  922,  929,  936,  942,
948,  953,  959,  963,  966,  969,  971,  973,  975,  977,  979,  980,  981,  982,  982,  983,
984,  984,  985,  985,  986,  986,  987,  987,  988,  988,  989,  989,  990,  990,  991,  991,
992,  992,  993,  993,  994,  994,  995,  995,  996,  996,  997,  997,  998,  998,  999,  999,
999, 1000, 1000, 1001, 1001, 1001, 1002, 1002, 1002, 1003, 1003, 1004, 1004, 1004, 1005, 1005,
1005, 1006, 1006, 1007, 1007, 1007, 1008, 1008, 1008, 1009, 1009, 1010, 1010, 1010, 1011, 1011,
1011, 1012, 1012, 1013, 1013, 1013, 1014, 1014, 1014, 1015, 1015, 1016, 1016, 1016, 1017, 1017,
1017, 1018, 1018, 1019, 1019, 1019, 1020, 1020, 1020, 1021, 1021, 1022, 1022, 1022, 1023, 1023
};

u16 dci_map_lut_50[] = {
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50
};

uint16_t lscr_lut[] = {
0x300,   0x310,  0x320,  0x330,  0x340,  0x350,  0x360,  0x370,
0x400,  0x410, 0x420, 0x430, 0x440, 0x450, 0x460, 0x470,
0x500, 0x510, 0x520, 0x530, 0x540, 4095, 4095, 4095,
4095, 4095, 4095, 4095, 4095, 4095, 4095, 4095,
};

/* for imx327 tuning */
struct isp_ccm_cfg ccm_hw_cfg = {
	.coef = {
			{1024, 0, 0},
			{0, 0, 0},
			{0, 0, 0},
		},
};

uint16_t gamma_data[] = {
0, 120, 220, 310, 390, 470, 540, 610, 670, 730, 786, 842, 894, 944, 994, 1050, 1096, 1138, 1178,
1218, 1254, 1280, 1314, 1346, 1378, 1408, 1438, 1467, 1493, 1519, 1543, 1568, 1592, 1615, 1638,
1661, 1683, 1705, 1726, 1748, 1769, 1789, 1810, 1830, 1849, 1869, 1888, 1907, 1926, 1945, 1963,
1981, 1999, 2017, 2034, 2052, 2069, 2086, 2102, 2119, 2136, 2152, 2168, 2184, 2200, 2216, 2231,
2247, 2262, 2277, 2292, 2307, 2322, 2337, 2351, 2366, 2380, 2394, 2408, 2422, 2436, 2450, 2464,
2477, 2491, 2504, 2518, 2531, 2544, 2557, 2570, 2583, 2596, 2609, 2621, 2634, 2646, 2659, 2671,
2683, 2696, 2708, 2720, 2732, 2744, 2756, 2767, 2779, 2791, 2802, 2814, 2825, 2837, 2848, 2859,
2871, 2882, 2893, 2904, 2915, 2926, 2937, 2948, 2959, 2969, 2980, 2991, 3001, 3012, 3023, 3033,
3043, 3054, 3064, 3074, 3085, 3095, 3105, 3115, 3125, 3135, 3145, 3155, 3165, 3175, 3185, 3194,
3204, 3214, 3224, 3233, 3243, 3252, 3262, 3271, 3281, 3290, 3300, 3309, 3318, 3327, 3337, 3346,
3355, 3364, 3373, 3382, 3391, 3400, 3409, 3418, 3427, 3436, 3445, 3454, 3463, 3471, 3480, 3489,
3498, 3506, 3515, 3523, 3532, 3540, 3549, 3557, 3566, 3574, 3583, 3591, 3600, 3608, 3616, 3624,
3633, 3641, 3649, 3657, 3665, 3674, 3682, 3690, 3698, 3706, 3714, 3722, 3730, 3738, 3746, 3754,
3762, 3769, 3777, 3785, 3793, 3801, 3808, 3816, 3824, 3832, 3839, 3847, 3855, 3862, 3870, 3877,
3885, 3892, 3900, 3907, 3915, 3922, 3930, 3937, 3945, 3952, 3959, 3967, 3974, 3981, 3989, 3996,
4003, 4010, 4018, 4025, 4032, 4039, 4046, 4054, 4061, 4068, 4075, 4082, 4089, 4095
};

uint16_t ygamma_data[] = {
0,        20,   40,     59,    79,    99,   119,   139,   159,   178,   198,   218,   240,   263,   286,   312,
338,     365,  394,    424,   456,   489,   523,   558,   595,   633,   673,   714,   756,   800,   845,   892,
940,     990,  1041,  1094,  1148,  1204,  1262,  1320,  1381,  1443,  1507,  1572,  1639,  1708,  1778,  1850,
1923,   1998,  2075,  2154,  2234,  2316,  2400,  2485,  2572,  2661,  2752,  2845,  2939,  3035,  3133,  3233,
3334,   3438,  3543,  3650,  3759,  3870,  3983,  4097,  4214,  4332,  4453,  4575,  4699,  4825,  4953,  5083,
5216,   5350,  5486,  5624,  5764,  5906,  6050,  6196,  6344,  6494,  6646,  6801,  6957,  7115,  7276,  7439,
7603,   7770,  7939,  8110,  8283,  8459,  8636,  8816,  8998,  9182,  9368,  9556,  9747,  9939, 10134, 10331,
10531, 10732, 10936, 11142, 11350, 11561, 11774, 11989, 12206, 12426, 12648, 12872, 13098, 13327, 13558, 13792,
14028, 14266, 14506, 14749, 14994, 15242, 15492, 15744, 15999, 16256, 16515, 16777, 17041, 17308, 17577, 17848,
18122, 18399, 18677, 18959, 19242, 19528, 19817, 20108, 20402, 20698, 20996, 21297, 21601, 21907, 22216, 22527,
22840, 23157, 23475, 23796, 24120, 24447, 24776, 25107, 25441, 25778, 26117, 26459, 26803, 27150, 27500, 27852,
28207, 28564, 28924, 29287, 29652, 30020, 30391, 30764, 31140, 31519, 31900, 32284, 32671, 33060, 33452, 33847,
34245, 34645, 35048, 35453, 35862, 36273, 36686, 37103, 37522, 37944, 38369, 38797, 39227, 39660, 40096, 40535,
40976, 41420, 41867, 42317, 42770, 43225, 43683, 44144, 44608, 45075, 45545, 46017, 46492, 46970, 47451, 47935,
48422, 48911, 49404, 49899, 50397, 50898, 51402, 51909, 52419, 52932, 53447, 53966, 54487, 55012, 55539, 56069,
56603, 57139, 57678, 58220, 58765, 59313, 59864, 60418, 60974, 61534, 62097, 62663, 63232, 63804, 64379, 64956,
65535
};

uint16_t ycur_data[] = {
255,  252,  248,  244,  240,  236,  232,  228,  224,  220,  216,  212,  208,  204,  200,  196,
192,  188,  184,  180,  176,  172,  168,  164,  160,  156,  152,  148,  144,  140,  136,  132,
128,  124,  120,  116,  112,  108,  104,  100,  96,   92,   88,   84,   80,   76,   72,   68,
64,   60,   56,   52,   48,   44,   40,   36,   32,   28,   24,   20,   16,   12,   8,    4,
0,
};

uint16_t ltm_d_lut[] = {
0, 256, 512, 768,  1024,  1280,  1536,  1792,  2048,  2304,  2560,  2816,  3072,  3328,  3584,  3840,  4096,
4352,  4608,  4864,  5120,  5376,  5632,  5888,  6144,  6400,  6656,  6912,  7168,  7424,  7680,  7936,  8192,
8448,  8704,  8960,  9216,  9472,  9728,  9984, 10240, 10496, 10752, 11008, 11264, 11520, 11776, 12032, 12288,
12544, 12800, 13056, 13312, 13568, 13824, 14080, 14336, 14592, 14848, 15104, 15360, 15616, 15872, 16128, 16384,
16640, 16896, 17152, 17408, 17664, 17920, 18176, 18432, 18688, 18944, 19200, 19456, 19712, 19968, 20224, 20480,
20736, 20992, 21248, 21504, 21760, 22016, 22272, 22528, 22784, 23040, 23296, 23552, 23808, 24064, 24320, 24576,
24832, 25088, 25344, 25600, 25856, 26112, 26368, 26624, 26880, 27136, 27392, 27648, 27904, 28160, 28416, 28672,
28928, 29184, 29440, 29696, 29952, 30208, 30464, 30720, 30976, 31232, 31488, 31744, 32000, 32256, 32512, 32768,
33024, 33280, 33536, 33792, 34048, 34304, 34560, 34816, 35072, 35328, 35584, 35840, 36096, 36352, 36608, 36864,
37120, 37376, 37632, 37888, 38144, 38400, 38656, 38912, 39168, 39424, 39680, 39936, 40192, 40448, 40704, 40960,
41216, 41472, 41728, 41984, 42240, 42496, 42752, 43008, 43264, 43520, 43776, 44032, 44288, 44544, 44800, 45056,
45312, 45568, 45824, 46080, 46336, 46592, 46848, 47104, 47360, 47616, 47872, 48128, 48384, 48640, 48896, 49152,
49408, 49664, 49920, 50176, 50432, 50688, 50944, 51200, 51456, 51712, 51968, 52224, 52480, 52736, 52992, 53248,
53504, 53760, 54016, 54272, 54528, 54784, 55040, 55296, 55552, 55808, 56064, 56320, 56576, 56832, 57088, 57344,
57600, 57856, 58112, 58368, 58624, 58880, 59136, 59392, 59648, 59904, 60160, 60416, 60672, 60928, 61184, 61440,
61696, 61952, 62208, 62464, 62720, 62976, 63232, 63488, 63744, 64000, 64256, 64512, 64768, 65024, 65280, 65535
};

uint16_t ltm_b_lut[] = {
0, 4096, 8192, 12288, 16384, 20480, 24576, 28672, 32768, 36864, 40960, 45056, 49152, 53248, 57344, 61440, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535
};

uint16_t ltm_g_lut[] = {
0, 256, 512, 768, 1024, 1280, 1536,  1792,  2048,  2304,  2560,  2816,  3072,  3328,  3584,  3840,  4096,
4352,  4608,  4864,  5120,  5376,  5632,  5888,  6144,  6400,  6656,  6912,  7168,  7424,  7680,  7936,  8192,
8448,  8704,  8960,  9216,  9472,  9728,  9984, 10240, 10496, 10752, 11008, 11264, 11520, 11776, 12032, 12288,
12544, 12800, 13056, 13312, 13568, 13824, 14080, 14336, 14592, 14848, 15104, 15360, 15616, 15872, 16128, 16384,
16640, 16896, 17152, 17408, 17664, 17920, 18176, 18432, 18688, 18944, 19200, 19456, 19712, 19968, 20224, 20480,
20736, 20992, 21248, 21504, 21760, 22016, 22272, 22528, 22784, 23040, 23296, 23552, 23808, 24064, 24320, 24576,
24832, 25088, 25344, 25600, 25856, 26112, 26368, 26624, 26880, 27136, 27392, 27648, 27904, 28160, 28416, 28672,
28928, 29184, 29440, 29696, 29952, 30208, 30464, 30720, 30976, 31232, 31488, 31744, 32000, 32256, 32512, 32768,
33024, 33280, 33536, 33792, 34048, 34304, 34560, 34816, 35072, 35328, 35584, 35840, 36096, 36352, 36608, 36864,
37120, 37376, 37632, 37888, 38144, 38400, 38656, 38912, 39168, 39424, 39680, 39936, 40192, 40448, 40704, 40960,
41216, 41472, 41728, 41984, 42240, 42496, 42752, 43008, 43264, 43520, 43776, 44032, 44288, 44544, 44800, 45056,
45312, 45568, 45824, 46080, 46336, 46592, 46848, 47104, 47360, 47616, 47872, 48128, 48384, 48640, 48896, 49152,
49408, 49664, 49920, 50176, 50432, 50688, 50944, 51200, 51456, 51712, 51968, 52224, 52480, 52736, 52992, 53248,
53504, 53760, 54016, 54272, 54528, 54784, 55040, 55296, 55552, 55808, 56064, 56320, 56576, 56832, 57088, 57344,
57600, 57856, 58112, 58368, 58624, 58880, 59136, 59392, 59648, 59904, 60160, 60416, 60672, 60928, 61184, 61440,
61696, 61952, 62208, 62464, 62720, 62976, 63232, 63488, 63744, 64000, 64256, 64512, 64768, 65024, 65280, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535,
65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535
};

#ifdef PORTING_TEST
uint16_t c_lut_r_lut[] = {
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
1023, 959, 895, 831, 767, 703, 639, 575, 511, 447, 383, 319, 255, 191, 127, 63, 0,
};

uint16_t c_lut_g_lut[] = {
1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023,
959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959,
895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895,
831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831,
767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767,
703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703,
639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639,
575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575,
511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511,
447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447,
383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383,
319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023,
959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959,
895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895,
831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831,
767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767,
703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703,
639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639,
575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575,
511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511,
447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447,
383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383,
319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023,
959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959,
895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895,
831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831,
767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767,
703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703,
639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639,
575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575,
511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511,
447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447,
383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383,
319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
127, 127, 127, 127, 127, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023,
959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959,
895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895,
831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831,
767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767,
703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703,
639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639,
575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575,
511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511,
447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447,
383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383,
319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023,
959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959,
895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895,
831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831,
767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767,
703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703,
639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639,
575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575,
511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511,
447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447,
383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383,
319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023,
959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959,
895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895,
831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831,
767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767,
703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703,
639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639,
575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575,
511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511,
447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447,
383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383,
319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023,
959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959,
895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895,
831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831,
767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767,
703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703,
639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639,
575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575,
511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511,
447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447,
383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383,
319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023,
959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959,
895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895,
831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831,
767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767,
703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703,
639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639,
575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575,
511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511,
447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447,
383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383,
319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023,
959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959,
895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895,
831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831,
767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767,
703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703,
639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639,
575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575,
511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511,
447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447,
383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383,
319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023,
959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959,
895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895,
831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831,
767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767,
703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703,
639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639,
575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575,
511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511,
447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447,
383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383,
319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023,
959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959,
895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895,
831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831,
767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767,
703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703,
639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639,
575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575,
511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511,
447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447,
383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383,
319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023,
959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959,
895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895,
831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831,
767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767,
703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703,
639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639,
575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575,
511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511,
447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447,
383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383,
319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023,
959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959,
895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895,
831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831,
767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767,
703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703,
639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639,
575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575,
511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511,
447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447,
383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383,
319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023,
959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959,
895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895,
831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831,
767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767,
703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703,
639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639,
575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575,
511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511,
447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447,
383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383,
319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023,
959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959,
895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895,
831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831,
767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767,
703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703,
639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639,
575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575,
511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511,
447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447,
383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383,
319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023,
959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959,
895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895,
831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831,
767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767,
703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703,
639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639,
575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575,
511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511,
447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447,
383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383,
319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023,
959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959,
895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895,
831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831,
767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767,
703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703,
639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639,
575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575,
511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511,
447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447,
383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383,
319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};

uint16_t c_lut_b_lut[] = {
1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023,
1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023,
1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023,
1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023,
1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023,
1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023,
1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023,
1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023,
1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023,
1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023,
1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023,
1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023,
1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023,
1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023,
1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023,
1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023,
1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023,
959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959,
959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959,
959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959,
959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959,
959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959,
959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959,
959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959,
959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959,
959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959,
959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959,
959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959,
959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959,
959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959,
959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959,
959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959,
959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959,
959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959, 959,
895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895,
895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895,
895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895,
895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895,
895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895,
895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895,
895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895,
895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895,
895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895,
895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895,
895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895,
895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895,
895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895,
895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895,
895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895,
895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895,
895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, 895,
831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831,
831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831,
831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831,
831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831,
831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831,
831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831,
831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831,
831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831,
831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831,
831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831,
831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831,
831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831,
831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831,
831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831,
831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831,
831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831,
831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, 831,
767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767,
767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767,
767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767,
767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767,
767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767,
767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767,
767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767,
767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767,
767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767,
767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767,
767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767,
767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767,
767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767,
767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767,
767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767,
767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767,
767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, 767,
703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703,
703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703,
703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703,
703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703,
703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703,
703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703,
703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703,
703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703,
703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703,
703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703,
703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703,
703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703,
703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703,
703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703,
703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703,
703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703,
703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703, 703,
639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639,
639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639,
639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639,
639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639,
639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639,
639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639,
639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639,
639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639,
639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639,
639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639,
639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639,
639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639,
639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639,
639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639,
639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639,
639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639,
639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639, 639,
575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575,
575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575,
575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575,
575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575,
575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575,
575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575,
575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575,
575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575,
575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575,
575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575,
575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575,
575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575,
575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575,
575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575,
575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575,
575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575,
575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, 575,
511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511,
511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511,
511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511,
511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511,
511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511,
511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511,
511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511,
511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511,
511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511,
511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511,
511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511,
511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511,
511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511,
511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511,
511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511,
511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511,
511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511,
447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447,
447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447,
447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447,
447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447,
447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447,
447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447,
447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447,
447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447,
447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447,
447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447,
447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447,
447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447,
447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447,
447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447,
447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447,
447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447,
447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, 447,
383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383,
383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383,
383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383,
383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383,
383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383,
383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383,
383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383,
383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383,
383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383,
383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383,
383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383,
383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383,
383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383,
383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383,
383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383,
383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383,
383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383,
319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
#endif

/*********************************************************************************************/
static int count;

/* control internal patgen
 *
 * 1: enable
 * 0: disable
 */
static int csi_patgen_en[ISP_PRERAW_MAX] = {0, 0};
module_param_array(csi_patgen_en, int, &count, 0644);

int burst_i2c_en;
module_param(burst_i2c_en, int, 0644);

/* runtime tuning control
 * ctrl:
 *	0: all ch stop update.
 *	1: stop after apply ch1 setting
 *	2: stop after apply ch2 setting
 */
int tuning_dis[4] = {0, 0, 0, 0}; //ctrl, fe, be, post
module_param_array(tuning_dis, int, &count, 0664);

/* Runtime to enable/disable isp_top_clk
 * Ctrl:
 *	0: Disable isp_top_clk dynamic contorl
 *	1: Enable isp_top_clk dynamic control
 */
int clk_dynamic_en;
module_param(clk_dynamic_en, int, 0644);

/* Runtime to enable rgbmap slice buffer mode
 * Ctrl:
 *	0: rgbmap use frame buffer mode.
 *	1: rgbmap use slice buffer mode.
 */
int rgbmap_sbm_en;
module_param(rgbmap_sbm_en, int, 0644);

/* Runtime to enable slice buffer mode
 * Ctrl:
 *	N: use frame buffer mode.
 *	Y: use slice buffer mode.
 */
bool sbm_en = true;
module_param(sbm_en, bool, 0644);

/* Runtime to enable bw limit
 * Ctrl:
 *	N: disable bw limit.
 *	Y: use bw limit.
 */
bool bw_en = true;
module_param(bw_en, bool, 0644);

/* Choose the ip test cases for FPGA verification
 * Ctrl:
 *	See the vi_ip_test_case.c for detail description of each test cases
 */
#ifdef PORTING_TEST
int vi_ip_test_case;
module_param(vi_ip_test_case, int, 0644);
#endif

void _pre_hw_enque(
	struct cvi_vi_dev *vdev,
	const enum cvi_isp_raw raw_num,
	const u8 chn_num);
void _isp_fe_be_raw_dump_cfg(
	struct cvi_vi_dev *vdev,
	const enum cvi_isp_raw raw_num,
	const u8 chn_num);
void isp_post_tasklet(unsigned long data);
static void _vi_sw_init(struct cvi_vi_dev *vdev);
#ifndef FPGA_PORTING
static int _vi_clk_ctrl(struct cvi_vi_dev *vdev, u8 enable);
#endif
static inline void vi_err_wake_up_th(struct cvi_vi_dev *vdev, enum cvi_isp_raw err_raw);
static inline void _post_rgbmap_update(struct isp_ctx *ctx, const enum cvi_isp_raw raw_num, const u32 frm_num);
static void vi_motion_level_calc(struct cvi_vi_dev *vdev, enum cvi_isp_raw raw_num,
				 uint8_t *motion_table, uint8_t *motion_lv);
static void vi_dci_calc(struct cvi_vi_dev *vdev, enum cvi_isp_raw raw_num, uint32_t *dci_lv);
void _postraw_outbuf_enq(struct cvi_vi_dev *vdev, const enum cvi_isp_raw raw_num);
void isp_fill_rgbmap(struct isp_ctx *ctx, enum cvi_isp_raw raw_num, const u8 chn_num);
struct cvi_isp_buf *_cvi_isp_next_buf(struct cvi_vi_dev *vdev, const u8 chn_num);

static int _vi_preraw_thread(void *arg);
static int _vi_vblank_handler_thread(void *arg);
static int _vi_err_handler_thread(void *arg);
static int _vi_event_handler_thread(void *arg);

#ifdef __cplusplus
}
#endif

#endif /* __VI_H__ */
